package ModelLayer.OrdreMappe;
import ModelLayer.LagerMappe.*;
import ModelLayer.PersonMappe.*;
import java.util.ArrayList;


/**
 * Write a description of class OrdreCon here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class OrdreCon
{
    private Ordre currentOrdre;
    private ArrayList<Ordre> alleOrdre;
      
    /**
     * Constructor for objects of class OrdreCon
     */
    public OrdreCon()
    {
        alleOrdre = new ArrayList<Ordre>();
    }
    
    public void setOrdre(Ordre newOrdre)
    {
        currentOrdre = newOrdre;
    }
    
    public void addVare(int antal, Lager lager, DelLager delLager)
    {
        if(currentOrdre != null)
        {
            currentOrdre.addVare(antal, lager, delLager);
            double currentPris = currentOrdre.getPris();
            currentOrdre.setPris(currentPris + antal * delLager.getVare().getSalgspris());
        }
    }
    
    public void createOrdre(int nr)
    {
        currentOrdre = new Ordre(nr);
    }
    
    public Ordre getOrdre()
    {
        return currentOrdre;
    }
    
    public ArrayList<Ordre> getAlleOrdre()
    {
        return alleOrdre;
    }
    
    public void confirmOrdre()
    {
        alleOrdre.add(currentOrdre);
        currentOrdre = null;
    }
    
    public void declineOrdre()
    {
        currentOrdre = null;
    }
    
    public void addPerson(Person p)
    {
        currentOrdre.addPerson(p);
    }
    
    public double getPris()
    {
        return currentOrdre.getPris();
    }
}
